package com.ljh.extensions.rabbit.config;

import com.ljh.extensions.rabbit.constants.Constants;
import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: Themberfue
 * @date: 2025/5/2 22:56
 * @description:
 */
@Configuration
public class QosConfig {
    @Bean("qosQueue")
    public Queue qosQueue() {
        return QueueBuilder.durable(Constants.QOS_QUEUE)
                .build();
    }
    @Bean("qosExchange")
    public DirectExchange qosExchange() {
        return ExchangeBuilder.directExchange(Constants.QOS_EXCHANGE)
                .durable(true)
                .build();
    }
    @Bean("qosBinding")
    public Binding qosBinding(@Qualifier("qosExchange") DirectExchange exchange, @Qualifier("qosQueue") Queue queue) {
        return BindingBuilder.bind(queue)
                .to(exchange)
                .with("qos");
    }
}
